cmake_minimum_required(VERSION 3.10)
project(grid_sampler_plugin)

# Set C++ standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find CUDA
find_package(CUDA REQUIRED)

# Set TensorRT paths
set(TENSORRT_ROOT "/data2/xd/TensorRT-8.5.1.7.Linux.x86_64-gnu.cuda-11.8.cudnn8.6/TensorRT-8.5.1.7")
set(TENSORRT_INCLUDE_DIRS "${TENSORRT_ROOT}/include")
set(TENSORRT_LIBRARIES "${TENSORRT_ROOT}/lib")

# Include directories
include_directories(
    ${CUDA_INCLUDE_DIRS}
    ${TENSORRT_INCLUDE_DIRS}
    ../common
    .
)

# CUDA compilation flags
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-std=c++14;-O3;-arch=sm_70)

# Create shared library
cuda_add_library(trtgrid_sampler SHARED
    trt_grid_sampler.cpp
    trt_grid_sampler_kernel.cu
)

# Link libraries
target_link_libraries(trtgrid_sampler
    ${CUDA_LIBRARIES}
    ${TENSORRT_LIBRARIES}/libnvinfer.so
    ${TENSORRT_LIBRARIES}/libnvonnxparser.so
)

# Set output directory
set_target_properties(trtgrid_sampler PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build"
) 